﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BLToolkit.DataAccess;
using Clipping.Utils;
using BLToolkit.Validation;
using System.IO;

namespace ClippingMaster
{
    [TableName(Name = "Keywords")]
    public class KEYWORDS : ModelBase<KEYWORDS>
    {
        class KEYWORDSUpdater : DBPartUpdater<KEYWORDSUpdater>
        {
            static KEYWORDSUpdater()
            {
                Actions[typeof(KEYWORDSUpdater)] = new List<UpdateAction>();

                #region 数据库升级脚本

                Versions[typeof(KEYWORDSUpdater)] = 0;

                #region 创建表 Keywords

                AddUpdateAction(typeof(KEYWORDSUpdater), @"CREATE TABLE Keywords(
ID VARCHAR2(100) NOT NULL,
CategoryID VARCHAR2(100) NOT NULL,
Keyword VARCHAR2(100) NOT NULL,
SearchType INTEGER NOT NULL,
SearchPeriod INTEGER NOT NULL
);      
");
                #endregion

                #endregion
            }
        }

        static KEYWORDS()
        {
            string keywordDBPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DB", "keywords.db");
            var keywordDBConnectionPool = DBHelper.CreateDBConnectionPool<KeywordDBUpdater>(keywordDBPath, 10);
            DBHelper.UpdateTableSchema<KEYWORDSUpdater>(keywordDBConnectionPool);
        }
           [PrimaryKey(0), Required]
        public string ID { get; set; }
        /// <summary>
        /// 类别ID
        /// </summary>
        [Required]
        public string CategoryId { get; set; }
        /// <summary>
        /// 关键词
        /// </summary>
        [Required]
        public string Keyword { get; set; }
        [Required]
        public int SearchType { get; set; }
        [Required]
        public int SearchPeriod { get; set; }
    }
}
